package org.linlinjava.litemall.taobaoke.controller;

import org.linlinjava.litemall.core.result.Response;
import org.linlinjava.litemall.taobaoke.DTO.*;
import org.linlinjava.litemall.taobaoke.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author haoting.wang
 * @date 2019-07-26 16:36
 **/
@RestController
@RequestMapping("/material")
public class MaterialController {


    @Autowired
    private MaterialService materialService;


    /**
     * 通用搜索
     *
     * @param materialQueryDTO
     * @return
     */
    @PostMapping("query")
    public Response<List<ItemInfo>> query(@RequestBody MaterialQueryDTO materialQueryDTO) {

        List<ItemInfo> itemInfos = materialService.query(materialQueryDTO);

        return Response.success(itemInfos);
    }


    /**
     * 精选
     *
     * @param materialFeaturedQueryDTO
     * @return
     */
    @PostMapping("query_featured")
    public Response<List<ItemInfo>> queryFeatured(@RequestBody MaterialFeaturedQueryDTO materialFeaturedQueryDTO) {

        List<ItemInfo> itemInfos = materialService.queryFeatured(materialFeaturedQueryDTO);

        return Response.success(itemInfos);
    }

    /**
     * 淘抢购
     *
     * @param tqgQueryDTO
     * @return
     */
    @PostMapping("query_tqg")
    public Response<List<ItemInfo>> queryTqg(@RequestBody TqgQueryDTO tqgQueryDTO) {

        List<ItemInfo> itemInfos = materialService.queryTqg(tqgQueryDTO);

        return Response.success(itemInfos);
    }
}
